package foodmaterial.entity;

import foodmaterial.action.valid.ObjectNullValid;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 食材
 */
public class FoodMaterial implements Serializable,Comparable<FoodMaterial> {
    private static final long serialVersionUID = -493586214622384163L;

    private Long id ;
    @ObjectNullValid(message = "食材分类不能为空")
    private Long typeId;// '参照食材分类id',
    private String typeName ;
    @NotEmpty(message = "食材名称不能为空")
    @Length(max=100,message = "食材名称最长{max}字符")
    private String name; // '名称',
    private String pic;// '食材图片路径，要限制上传大小',
    @Length(max=100,message = "规格最长{max}字符")
    private String specs;// '规格',
    @Length(max=100,message = "品牌最长{max}字符")
    private String brand ; //'品牌',
    private Double raxRate; // '税率',
    private String unitName; //'计量单位',
    @DecimalMin(value = "0",message = "能量最低为{value}")
    private Double energy ;// '能量',
    @DecimalMin(value = "0",message = "蛋白质最低为{value}")
    private Double protein; // '蛋白质',
    @DecimalMin(value = "0",message = "脂肪最低为{value}")
    private Double fat; //'脂肪',
    @DecimalMin(value = "0",message = "碳水化合物最低为{value}")
    private Double carbohydrate;// '碳水化合物',
    @DecimalMin(value = "0.01",message = "销售价格最低为{value}")
    @DecimalMax(value = "1000",message = "销售价格最高为{value}")
    private BigDecimal salePrice; //'食材价格（出货价格）',
    private BigDecimal oldSalePrice ; //老的价格，为批量更新的时候使用
    private BigDecimal buyPrice ;
    private BigDecimal grossMargin ;//毛利润，前端使用，后端不使用
    private Date lastBuyDate ;
    private Boolean enableUpdateBuyPrice ;
    @DecimalMax(value = "500000",message = "库存最大是{value}")
    @DecimalMin(value = "0",message = "库存最小是{value}")
    private BigDecimal amount; //库存数量'
    private Boolean stop ; //停用标志 true :停用 false ：在用
    @Min(value = 1,message = "分配单位最小是{value}")
    @Max(value = 500,message = "分配单位最大是{value}")
    private Integer expressionUnit ; //计算单位
    private Boolean supplier ; //标签打印区分供应商
    private Boolean originalProcess ;
    private Double originalProcessRate ;
    private Long originalType ;
    private String originalTypeName ;
    private Boolean processPurchase ;
    private Boolean condiment ; //订单查询的时候使用，主要是确定显示调料
    private Integer showOrder ;//公司调整食材的推荐顺序

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getTypeId() {
        return typeId;
    }

    public void setTypeId(Long typeId) {
        this.typeId = typeId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getSpecs() {
        return specs;
    }

    public void setSpecs(String specs) {
        this.specs = specs;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public Double getRaxRate() {
        return raxRate;
    }

    public void setRaxRate(Double raxRate) {
        this.raxRate = raxRate;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public Double getEnergy() {
        return energy;
    }

    public void setEnergy(Double energy) {
        this.energy = energy;
    }

    public Double getProtein() {
        return protein;
    }

    public void setProtein(Double protein) {
        this.protein = protein;
    }

    public Double getFat() {
        return fat;
    }

    public void setFat(Double fat) {
        this.fat = fat;
    }

    public Double getCarbohydrate() {
        return carbohydrate;
    }

    public void setCarbohydrate(Double carbohydrate) {
        this.carbohydrate = carbohydrate;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
        this.setOldSalePrice(salePrice);
    }

    public BigDecimal getBuyPrice() {
        return buyPrice;
    }

    public void setBuyPrice(BigDecimal buyPrice) {
        this.buyPrice = buyPrice;
    }

    public BigDecimal getGrossMargin() {
        return grossMargin;
    }

    public void setGrossMargin(BigDecimal grossMargin) {
        this.grossMargin = grossMargin;
    }

    public Date getLastBuyDate() {
        return lastBuyDate;
    }

    public void setLastBuyDate(Date lastBuyDate) {
        this.lastBuyDate = lastBuyDate;
    }

    public Boolean getEnableUpdateBuyPrice() {
        return enableUpdateBuyPrice;
    }

    public void setEnableUpdateBuyPrice(Boolean enableUpdateBuyPrice) {
        this.enableUpdateBuyPrice = enableUpdateBuyPrice;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Boolean getStop() {
        return stop;
    }

    public void setStop(Boolean stop) {
        this.stop = stop;
    }

    public Integer getExpressionUnit() {
        return expressionUnit;
    }

    public void setExpressionUnit(Integer expressionUnit) {
        this.expressionUnit = expressionUnit;
    }

    public Boolean getSupplier() {
        return supplier;
    }

    public void setSupplier(Boolean supplier) {
        this.supplier = supplier;
    }

    public Boolean getOriginalProcess() {
        return originalProcess;
    }

    public void setOriginalProcess(Boolean originalProcess) {
        this.originalProcess = originalProcess;
    }

    public Double getOriginalProcessRate() {
        return originalProcessRate;
    }

    public void setOriginalProcessRate(Double originalProcessRate) {
        this.originalProcessRate = originalProcessRate;
    }

    public Long getOriginalType() {
        return originalType;
    }

    public void setOriginalType(Long originalType) {
        this.originalType = originalType;
    }

    public String getOriginalTypeName() {
        return originalTypeName;
    }

    public void setOriginalTypeName(String originalTypeName) {
        this.originalTypeName = originalTypeName;
    }

    public Boolean getProcessPurchase() {
        return processPurchase;
    }

    public void setProcessPurchase(Boolean processPurchase) {
        this.processPurchase = processPurchase;
    }

    public Boolean getCondiment() {
        return condiment;
    }

    public void setCondiment(Boolean condiment) {
        this.condiment = condiment;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public BigDecimal getOldSalePrice() {
        return oldSalePrice;
    }

    public void setOldSalePrice(BigDecimal oldSalePrice) {
        this.oldSalePrice = oldSalePrice;
    }

    public Integer getShowOrder() {
        return showOrder;
    }

    public void setShowOrder(Integer showOrder) {
        this.showOrder = showOrder;
    }

    @Override
    public int compareTo(FoodMaterial o) {
        if (this.getId().longValue() > o.getId().longValue()) return 1 ;
        else if (this.getId().longValue() == o.getId().longValue()) return 0;
        else return -1 ;
    }
}
